
#include <algorithm>
#include <iostream>
#include <vector>
//
// Created by lingzhitech on 25-11-6.
//
struct absInt {
    int operator()(int value) {
        return (value >= 0 ? value : -value);
    }
};

class PrintString {
public:
    PrintString(std::ostream &o = std::cout, char c = ' '):os(o), sep(c){}
    void operator()(const std::string &s) const {
        os << s << sep;
    }

private:
    std::ostream &os;
    char sep;
};
int main() {
    // absInt absObject;
    // std::cout << absObject(55) << std::endl;

    PrintString printer;
    printer("Hello, World!");
    // PrintString errors(std::cerr, '\n');
    // errors("hello, world");

    std::vector<std::string> vs{"hello","world", "hello"};
    std::for_each(vs.begin(), vs.end(), printer);
}